import axios from '@/libs/axios1'
let jsonHeaders = { 'content-type': 'application/json;charset=UTF-8' }
let base = '/testplatform/testBug'

// 查询bug列表
export const queryBugList = params => {
  return axios({
    url: `${base}`,
    method: 'GET',
    params,
    headers: jsonHeaders,
  })
}

// 创建bug
export const addBug = data => {
  return axios({
    url: `${base}`,
    method: 'POST',
    data,
    headers: jsonHeaders,
  })
}

// 修改bug
export const updateBug = data => {
  return axios({
    url: `${base}`,
    method: 'PUT',
    data,
    headers: jsonHeaders,
  })
}

// 删除bug
export const deleteBug = id => {
  return axios({
    url: `${base}/${id}`,
    method: 'DELETE',
    headers: jsonHeaders,
  })
}

// 关闭bug
export const closeBug = data => {
  return axios({
    url: `${base}/close`,
    method: 'PUT',
    data,
    headers: jsonHeaders,
  })
}

// 通过bug查询关联的测试项目
export const queryTestProjectListByBug = id => {
  return axios({
    url: `${base}/getTestPrjByBugId`,
    method: 'GET',
    params: {
      id
    },
    headers: jsonHeaders,
  })
}

// 查询bug日志列表
export const queryBugLogList = params => {
  return axios({
    url: `${base}/log`,
    method: 'GET',
    params,
    headers: jsonHeaders,
  })
}

// 创建bug日志
export const addBugLog = data => {
  return axios({
    url: `${base}/log`,
    method: 'POST',
    data,
    headers: jsonHeaders,
  })
}

// 修改bug日志
export const updateBugLog = data => {
  return axios({
    url: `${base}/log`,
    method: 'PUT',
    data,
    headers: jsonHeaders,
  })
}

// 删除bug日志
export const deleteBugLog = id => {
  return axios({
    url: `${base}/log/${id}`,
    method: 'DELETE',
    headers: jsonHeaders,
  })
}
